﻿//////////////////////////////////////////////////////////////////////////////
//
//  Copyright © 1998-2024 Glodon Company Limited.  All rights reserved.
//
//  Use of this software is subject to the terms of the Glodon license
//  agreement provided at the time of installation or download, or which
//  otherwise accompanies this software in either electronic or hard copy form.  
//
//////////////////////////////////////////////////////////////////////////////

// Reviewed

#pragma once

#include "GcmpRenderingInterface.h"
#include "RenderEnums.h"
#include "Vector3d.h"
#include "Vector2i.h"
#include "Matrix4d.h"

namespace gcmp
{
    /// \brief 视图相机
    ///
    /// 视图相机接口
    class GCMP_RENDERING_INTERFACE_EXPORT ICamera
    {
    public:
        virtual ~ICamera();

        /// \brief 取得相机的所有参数信息
        /// \param type 相机类型
        /// \param position 位置
        /// \param direction 视线方向
        /// \param upDirection 上方向
        /// \param aspectRatio 视口宽高比
        /// \param nearDist 近裁剪面距离
        /// \param farDist 远裁剪面距离
        /// \param perspectiveFieldOfView 相机张角，仅透视投影有效
        /// \param orthoWindowHeight 观察窗口高度，仅正交模式有效
        virtual void GetAllParameters(CameraType& type, Vector3d& position, Vector3d& direction, Vector3d& upDirection,
                                    double& aspectRatio, double& nearDistance, double& farDistance,
                                    double& perspectiveFieldOfView, double& orthoWindowHeight) const = 0;

        /// \brief 设置相机的所有参数信息
        /// \param type 相机类型
        /// \param position 位置
        /// \param direction 视线方向
        /// \param upDirection 上方向
        /// \param aspectRatio 视口宽高比
        /// \param nearDist 近裁剪面距离
        /// \param farDist 远裁剪面距离
        /// \param perspectiveFieldOfView 相机张角，仅透视投影有效
        /// \param orthoWindowHeight 观察窗口高度，仅正交模式有效
        virtual void SetAllParameters(CameraType type, const Vector3d& position, const Vector3d& direction,
                                    const Vector3d& upDirection, double aspectRatio, double nearDistance, double farDistance,
                                    double perspectiveFieldOfView, double orthoWindowHeight) = 0;

        /// \brief 设置是否为正投影
        /// \param value 是否为正投影
        virtual void SetOrtho(bool value) = 0;

        /// \brief 获取相机的上方向
        /// \return 相机的上方向
        virtual Vector3d GetUpDirection() const = 0;

        /// \brief 获取相机指向的方向
        /// \return 相机指向的方向
        virtual Vector3d GetDirection() const = 0;

        /// \brief 获取相机的位置
        /// \param position 相机位置 
        /// \return 
        virtual void SetPosition(const Vector3d &position) = 0;

        /// \brief 获取相机指向的位置
        /// \return 相机位置
        virtual Vector3d GetPosition() const = 0;

        /// \brief 获取相机对应的视图矩阵
        /// \return 视图矩阵
        virtual Matrix4d GetViewMatrix() const = 0;

        /// \brief 获取相机对应的投影矩阵
        /// \return 投影矩阵
        virtual Matrix4d GetProjectionMatrix() const = 0;

        /// \brief 视口位置到世界位置转换
        /// \param viewportPos 相对视口位置
        /// \param depth 深度（0到1）
        /// \param width 视口宽度
        /// \param height 视口高度
        /// \return 世界位置
        virtual Vector3d ViewportPositionToWorldPosition(const Vector2i& viewportPosition, float depth, int width, int height) const = 0;

    };
}

